<script setup>
import { ref, onMounted } from "vue";
import http from "@/utils/http.js";

const params = {
    key:"bf558549cdf0671d14c2eb1e577f9fc5",
    city:"金华"
}

const weatherData = ref(null);
const getWeather = async () => {
    const response = await http.get("/simpleWeather/query", {params});
    weatherData.value = response.result;
};
onMounted(() => {
    getWeather();
});
</script>

<template>
  <div>
    <h1>天气预报(金华)</h1>
    <div>
       <p>温度：{{ weatherData?.temperature }}</p> 
       <p>湿度：{{ weatherData?.humidity }}</p> 
       <p>空气质量指数：{{ weatherData?.api }}</p> 
    </div>
  </div>
</template>

<style scoped>

</style>
